//
//  UIBarButtonItem+GXWExtension.m
//  百思 MJ
//
//  Created by 龚昕炜 on 16/7/18.
//  Copyright © 2016年 龚昕炜. All rights reserved.
//

#import "UIBarButtonItem+GXWExtension.h"

@implementation UIBarButtonItem (GXWExtension)

+ (instancetype)itemWithImageName:(NSString *)imageName hightLightImageName:(NSString *)hightLightImageName target:(id)target action:(SEL)action
{
    /** button */
    UIButton *leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [leftBtn setBackgroundImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [leftBtn setBackgroundImage:[UIImage imageNamed:hightLightImageName] forState:UIControlStateHighlighted];
//    leftBtn.size = leftBtn.currentBackgroundImage.size;
    [leftBtn sizeToFit];
    [leftBtn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    /** 包成item */
    UIBarButtonItem *leftItem = [[self alloc] initWithCustomView:leftBtn];
    
    return leftItem;
}

@end
